package com.林子祺.全名健康管理系统.dao.content.comment;

import java.sql.*;

public class DeleteComment {
    public static void delete(String name,String article,String text) {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/content?useUnicode=true&characterEncoding=utf-8", "root", "blink102417");

            String sql = "delete from comment where username =" + "'" + name + "' and articlename =" + "'"+article+"' and comment =" + "'"+text+"'";

            stmt = conn.createStatement();

            stmt.execute(sql);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
        }
    }
}
